<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    {include file='base/common_header'}
    <style>
        .w-e-toolbar{
            flex-wrap:wrap;
        }
    </style>
</head>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form topic-form layui-col-space10">
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>管理员名称</label>
                    <div class="layui-input-inline">
                        <input type="text" id="username" value="{$typeInfo.username}" name="username" required="" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="username2" class="layui-form-label">
                        <span class="x-red">*</span>登陆密码</label>
                    <div class="layui-input-inline">
                        <input type="text" id="password" name="password"  autocomplete="off" class="layui-input">
                        <p><span class="x-red">密码为空则用回当前密码</span></p>
                    </div>
                </div>
                {if condition="$typeInfo.is_super neq 1"}
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>选择角色</label>
                    <div class="layui-input-inline">
                        {if condition="!empty($roleList)"}
                        <select id="category" name="roles_id" class="valid" lay-verify="required">
                            {volist name="roleList" id="v"}
                            <option value="{$v.id}" {if condition="$typeInfo.roles_id eq $v.id"}selected{/if}>{$v.role_name}</option>
                            {/volist}
                        </select>
                        {/if}
                    </div>
                </div>
                {/if}
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label"></label>
                <input type="hidden" name="id" value="{$typeInfo.id}">
                <button class="layui-btn" lay-filter="add" lay-submit="">更新</button></div>
        </form>
    </div>
</div>
<script>
    layui.use(['form', 'layer'],
        function() {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;
            //监听提交
            form.on('submit(add)',
                function(data) {
                    $.post("/admin/admin/deal",$('.topic-form').serialize(),function (res) {
                        if(res.error_code != 0){
                            layer.msg(res.msg,{icon:5});
                        }else{
                            //发异步，把数据提交给php
                            layer.msg("更新成功", {
                                    icon: 6
                                },
                                function() {
                                    window.parent.location.reload();
                                    // 获得frame索引
                                    var index = parent.layer.getFrameIndex(window.name);
                                    //关闭当前frame
                                    parent.layer.close(index);
                                });
                        }
                    },'json')
                    return false;
                });
        });



</script>
</body>

</html>